<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<title>通知公告管理</title>
		<link rel="stylesheet" href="/resources/bootstrap/css/bootstrap-datetimepicker.min.css" />
		<style>
.ui-datalist .ui-widget-content {
	border: none;
}

#detailForm ol {
	padding-left: 7px;
}

.publish {
	background-color: #ADD8E6;
}

.unpublish {
	background-color: #F4A460;
}

.ui-datatable-scrollable-header-box {
	margin-left: 0px;
	margin-right: 15px !important;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="btnForm">
				<p:growl id="msg" showDetail="true" />
				<div class="box-header" id="queryDiv">
					<p:outputLabel value="发布时间:" for="sPublishTime" style="margin-right:5px;margin-left:10px;" />
					<p:calendar id="sPublishTime" pattern="yyyy-MM-dd" navigator="true" autocomplete="off"
						value="#{noticeManageView.sPublishTime}" />
					<p:outputLabel for="ePublishTime" value="至" style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="ePublishTime" pattern="yyyy-MM-dd" navigator="true" autocomplete="off"
						value="#{noticeManageView.ePublishTime}" />
					<p:outputLabel value="标题:" for="title" style="margin-right:5px;margin-left:10px;" />
					<p:inputText id="title" value="#{noticeManageView.title}"></p:inputText>
					<p:commandButton id="searchBtn" value="查询" update="form" icon="ui-icon-search"
						style="margin-left:30px" actionListener="#{noticeManageView.searchByCondition}"
						oncomplete="getTableScrollHeight();" />
					<p:commandButton id="clearBtn" value="重置" update="btnForm form " icon="ui-icon-refresh"
						actionListener="#{noticeManageView.clearCondition}" oncomplete="getTableScrollHeight();" />
					<div class="box-tools" style="float: right; margin-right: 20px">
						<button type="button" id="selectButton" title="高级查询" class="btn btn-default"
							onclick="onSelectDivClick();" style="margin-right: 10px;">
							<span id="selectButtonIcon" class="fa fa-caret-down">高级查询</span>
						</button>
					</div>
				</div>
				<div class="panel-collapse collapse" id="selectDiv">
					<p:outputLabel value="有效日期:" for="sValidTime" style="margin-right:5px;margin-left:10px;" />
					<p:calendar id="sValidTime" pattern="yyyy-MM-dd" autocomplete="off" navigator="true"
						value="#{noticeManageView.sValidTime}" />
					<p:outputLabel for="eValidTime" value="至" style="margin-right:5px;margin-left:5px;" />
					<p:calendar id="eValidTime" pattern="yyyy-MM-dd" autocomplete="off" navigator="true"
						value="#{noticeManageView.eValidTime}">
					</p:calendar>
				</div>
				<div id="toolbarDiv">
					<p:toolbar id="btns">
						<f:facet name="left">
							<p:commandButton id="createBtn" value="新增" icon="ui-icon-plus"
								actionListener="#{noticeManageView.preCreate}" update="createForm:createDlg form"
								oncomplete="PF('createDlg').show()" />
							<p:commandButton id="publishBtn" value="发布" icon="ui-icon-plus"
								disabled="#{noticeManageView.selectedNotice==null || noticeManageView.selectedNotice.publish==true}"
								actionListener="#{noticeManageView.setPublish}" update="form"
								oncomplete="getTableScrollHeight();">
								<p:confirm header="提示" message="确定发布该记录吗?" icon="ui-icon-alert" />
							</p:commandButton>
							<p:commandButton id="deleteBtn" value="删除" icon="ui-icon-trash"
								actionListener="#{noticeManageView.delete}" update="form btns"
								oncomplete="getTableScrollHeight();"
								disabled="#{noticeManageView.selectedNotice==null || noticeManageView.selectedNotice.createrCode!=noticeManageView.userCode}">
								<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
							</p:commandButton>
							<p:commandButton id="seeDetailBtn" value="详情"
								disabled="#{noticeManageView.selectedNotice==null}" icon="ui-icon-search"
								oncomplete="PF('detailDlg').show()" />
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:dataTable id="dataTb" widgetVar="item" var="item" rowKey="#{item.id}" emptyMessage="无记录"
					style="margin-bottom:20px" rows="15" paginator="true"
					selection="#{noticeManageView.selectedNotice}"
					rowStyleClass="#{noticeManageView.getRowClass(item)}"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="15,20,50" paginatorPosition="bottom" value="#{noticeManageView.notices}"
					rowIndexVar="ite" scrollable="true">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{noticeManageView.notices.size()} 条记录" style="margin-right:20px;" />
					</f:facet>
					<p:ajax event="rowSelectRadio"
						update="btnForm:seeDetailBtn detailForm:detailDlg btnForm:deleteBtn btnForm:publishBtn"
						listener="#{noticeManageView.onNoticeSelect}" />
					<p:column selectionMode="single" width="40" style="text-align:center" />
					<p:column width="60" headerText="序号" style="text-align:center">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="标题" style="text-align:center">
						<h:outputText value="#{item.title}" />
					</p:column>
					<p:column headerText="有效期至" style="text-align:center">
						<h:outputText value="#{item.validDate}">
							<f:convertDateTime pattern="yyyy-MM-dd"></f:convertDateTime>
						</h:outputText>
					</p:column>
					<p:column headerText="创建人" style="text-align:center">
						<h:outputText value="#{item.createrName}" />
					</p:column>
					<p:column headerText="创建时间" style="text-align:center">
						<h:outputText value="#{item.createTime}">
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"></f:convertDateTime>
						</h:outputText>
					</p:column>
					<p:column headerText="发布时间" style="text-align:center">
						<h:outputText value="#{item.publishTime}">
							<f:convertDateTime pattern="yyyy-MM-dd"></f:convertDateTime>
						</h:outputText>
					</p:column>
					<p:column headerText="是否发布" style="text-align:center">
						<h:outputText value="#{item.publish==true?'已发布':'未发布'}" />
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="detailForm">
				<p:dialog widgetVar="detailDlg" header="详情" modal="true" id="detailDlg" width="700" height="500">
					<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
					<p:ajax event="close" listener="#{noticeManageView.onDetailDlgClose}" update="detailDlg" />
					<p:toolbar rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}">
						<f:facet name="left">
							<p:commandButton id="editSaveBtn" value="保存" icon="ui-icon-disk"
								actionListener="#{noticeManageView.saveEdit}"
								oncomplete="refreshNotice();getTableScrollHeight();"
								disabled="#{noticeManageView.saveCanUse==false}" update="form btnForm:msg " />
							<p:commandButton value="取消" icon="ui-icon-cancel" oncomplete="PF('detailDlg').hide()" />
						</f:facet>
					</p:toolbar>
					<p:panelGrid style="width:100%">
						<p:row>
							<p:column style="width:100px">
								<p:outputLabel value="标题" />
								<h:outputText style="color:red;font-size:20px" value="*"
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"></h:outputText>
							</p:column>
							<p:column colspan="3">
								<h:outputText style="width:100%" value="#{noticeManageView.selectedNotice.title}"
									rendered="#{noticeManageView.selectedNotice.createrCode!=noticeManageView.userCode}" />
								<p:inputText style="width:100%" value="#{noticeManageView.selectedNotice.title}"
									autocomplete="off"
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}">
									<p:ajax event="blur" listener="#{noticeManageView.checkTitleExist}" update="editSaveBtn"></p:ajax>
								</p:inputText>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="内容" />
							</p:column>
							<p:column colspan="3">
								<h:inputTextarea disabled="true" style="width:100%;opacity:1;border:none"
									value="#{noticeManageView.selectedNotice.content}"
									rendered="#{noticeManageView.selectedNotice.createrCode!=noticeManageView.userCode}" />
								<h:inputTextarea style="width:100%" value="#{noticeManageView.selectedNotice.content}"
									autocomplete="off"
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"></h:inputTextarea>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="创建人" />
							</p:column>
							<p:column>
								<h:outputText style="width:100%" value="#{noticeManageView.selectedNotice.createrName}" />
							</p:column>
							<p:column>
								<p:outputLabel value="创建时间" />
							</p:column>
							<p:column>
								<h:outputText style="width:100%" value="#{noticeManageView.selectedNotice.createTime}">
									<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"></f:convertDateTime>
								</h:outputText>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="发布范围" />
							</p:column>
							<p:column>
								<h:outputText id="scope" style="width:100%"
									value="#{noticeManageView.selectedNotice.publishScopeNames}" />
								<p:commandButton
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"
									icon="ui-icon-pencil" title="修改" actionListener="#{noticeManageView.openOrgDlg}"
									style="margin-left: 8px;vertical-align: middle;width: 20px;height: 20px;">
									<p:ajax event="dialogReturn" listener="#{noticeManageView.onOrgSelected}" update="scope"></p:ajax>
								</p:commandButton>
							</p:column>
							<p:column>
								<p:outputLabel value="发布时间" />
							</p:column>
							<p:column>
								<h:outputText style="width:100%" value="#{noticeManageView.selectedNotice.publishTime}"
									rendered="#{noticeManageView.selectedNotice.publish==true}">
									<f:convertDateTime pattern="yyyy-MM-dd"></f:convertDateTime>
								</h:outputText>
								<p:calendar pattern="yyyy-MM-dd" navigator="true" style="width:100%"
									value="#{noticeManageView.selectedNotice.publishTime}" mindate="Date()"
									rendered="#{noticeManageView.selectedNotice.publish==false}" autocomplete="off">
								</p:calendar>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="有效期至" />
								<h:outputText style="color:red;font-size:20px" value="*"
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"></h:outputText>
							</p:column>
							<p:column colspan="3">
								<h:outputText style="width:100%" value="#{noticeManageView.selectedNotice.validDate}"
									rendered="#{noticeManageView.selectedNotice.createrCode!=noticeManageView.userCode}">
									<f:convertDateTime pattern="yyyy-MM-dd"></f:convertDateTime>
								</h:outputText>
								<p:calendar style="width:100%" pattern="yyyy-MM-dd" navigator="true"
									value="#{noticeManageView.selectedNotice.validDate}" mindate="Date()"
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"
									autocomplete="off">
									<p:ajax event="blur" listener="#{noticeManageView.checkValidDateExist}"
										update="editSaveBtn"></p:ajax>
									<p:ajax event="dateSelect" listener="#{noticeManageView.onDateSelect}" update="editSaveBtn"></p:ajax>
								</p:calendar>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="附件" />
								<p:commandLink
									rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"
									style="color:#1b82d7;text-decoration:underline" onclick=" PF('fileUpLoadDlg').show();">
									<span class="glyphicon glyphicon-upload"></span>
									<h:outputText value="上传" />
								</p:commandLink>
							</p:column>
							<p:column colspan="3">
								<p:dataList id="attachmentCol" var="attachment" value="#{noticeManageView.attachments}"
									type="ordered" emptyMessage="">
									<div>
										<p:commandLink value="#{attachment.description}" ajax="false" charset="utf-8"
											style="color:blue;text-decoration:underline"
											actionListener="#{noticeManageView.downLoadFile(attachment)}">
											<p:fileDownload value="#{noticeManageView.downloadedFile}"></p:fileDownload>
										</p:commandLink>
										<h:outputText value="（" />
										<h:outputText value="#{attachment.uploadDate}">
											<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"></f:convertDateTime>
										</h:outputText>
										<h:outputText value="）" />
										<h:outputText value="下载次数:#{attachment.downloadCount}"></h:outputText>
										<p:commandButton icon="ui-icon-close" title="删除"
											style="background:#dd4b39;border: 1px solid #dd4b39;margin-left: 8px;vertical-align: middle;width: 15px;height: 15px;"
											rendered="#{noticeManageView.selectedNotice.createrCode==noticeManageView.userCode}"
											update="detailForm:attachmentCol"
											actionListener="#{noticeManageView.deleteFile(attachment)}">
											<p:confirm header="提示" message="确定删除该附件吗?" icon="ui-icon-alert" />
										</p:commandButton>
									</div>
								</p:dataList>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:dialog>
				<p:dialog header="上传附件" height="300" width="600" modal="true" widgetVar="fileUpLoadDlg"
					resizable="true" dynamic="true" id="fileUpLoadDlg">
					<p:fileUpload label="选择" update="attachmentCol createForm:createAttachmentCol" multiple="true"
						uploadLabel="上传" cancelLabel="取消" style="margin-top:10px"
						fileUploadListener="#{noticeManageView.handleFileUpload}" mode="advanced"
						oncomplete="PF('fileUpLoadDlg').hide()" />
				</p:dialog>
				<p:dialog widgetVar="repeatDlg" id="repeatDlg" header="提示" modal="true" width="400">
					<p:outputLabel value="文件已存在，是否替换？" style="margin-left:30px;" />
					<p style="margin-left: 30px;">文件名称：</p>
					<p:dataList value="#{noticeManageView.repeatFileNames}" var="fileName">
						#{fileName}
					</p:dataList>
					<p:commandButton actionListener="#{noticeManageView.replaceFile}"
						oncomplete="PF('repeatDlg').hide()" value="替换" style="margin-left:30px;margin-top:10px;"
						update="repeatDlg attachmentCol createForm:createAttachmentCol" />
					<p:commandButton oncomplete="PF('repeatDlg').hide()" value="撤销" style="margin-top:10px;"
						update="repeatDlg" actionListener="#{noticeManageView.cancelReplaceFile}" />
				</p:dialog>
			</h:form>
			<h:form id="createForm">
				<p:dialog widgetVar="createDlg" header="新增" modal="true" id="createDlg" width="700" height="500">
					<p:ajax event="close" listener="#{noticeManageView.onCreateDlgClose}" update="createDlg" />
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" icon="ui-icon-disk"
								actionListener="#{noticeManageView.saveCreate}" update="form btnForm" oncomplete="getTableScrollHeight();" />
							<p:commandButton value="取消" icon="ui-icon-cancel"
								oncomplete="PF('createDlg').hide();getTableScrollHeight();" />
						</f:facet>
					</p:toolbar>
					<p:panelGrid style="width:100%">
						<p:row>
							<p:column>
								<p:outputLabel value="标题" />
								<p:outputLabel style="color:red;margin-top:5px;" value="*"></p:outputLabel>
							</p:column>
							<p:column colspan="3">
								<p:inputText style="width:100%" value="#{noticeManageView.created.title}" autocomplete="off" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="内容" />
							</p:column>
							<p:column colspan="3">
								<h:inputTextarea style="width:100%" value="#{noticeManageView.created.content}"
									autocomplete="off"></h:inputTextarea>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="创建人" />
							</p:column>
							<p:column>
								<h:outputText style="width:100%" value="#{noticeManageView.created.createrName}" />
							</p:column>
							<p:column>
								<p:outputLabel value="创建时间" />
							</p:column>
							<p:column>
								<h:outputText style="width:100%" value="#{noticeManageView.created.createTime}">
									<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"></f:convertDateTime>
								</h:outputText>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="发布范围" />
							</p:column>
							<p:column>
								<h:outputText id="cscope" value="#{noticeManageView.created.publishScopeNames}" />
								<p:commandButton icon="ui-icon-pencil" title="修改"
									actionListener="#{noticeManageView.openOrgDlg}"
									style="margin-left: 8px;vertical-align: middle;width: 20px;height: 20px;">
									<p:ajax event="dialogReturn" listener="#{noticeManageView.onOrgSelected}" update="cscope"></p:ajax>
								</p:commandButton>
							</p:column>
							<p:column>
								<p:outputLabel value="发布时间" />
							</p:column>
							<p:column>
								<p:calendar pattern="yyyy-MM-dd" navigator="true" mindate="Date()"
									value="#{noticeManageView.created.publishTime}" autocomplete="off">
								</p:calendar>
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="有效期至" />
								<p:outputLabel style="color:red" value="*"></p:outputLabel>
							</p:column>
							<p:column colspan="3">
								<p:calendar pattern="yyyy-MM-dd" navigator="true" mindate="Date()"
									value="#{noticeManageView.created.validDate}" autocomplete="off" style="width:100%" />
							</p:column>
						</p:row>
						<p:row>
							<p:column>
								<p:outputLabel value="附件" />
								<p:commandLink style="color:#1b82d7;text-decoration:underline"
									onclick=" PF('fileUpLoadDlg').show();">
									<span class="glyphicon glyphicon-upload"></span>
									<h:outputText value="上传" />
								</p:commandLink>
							</p:column>
							<p:column colspan="3">
								<p:outputPanel id="createAttachmentCol">
									<p:repeat var="attachment" value="#{noticeManageView.attachments}">
										<div>
											<h:outputText value="#{attachment.description}"></h:outputText>
											<p:commandButton icon="ui-icon-close" title="删除"
												style="background:#dd4b39;border: 1px solid #dd4b39;margin-left: 8px;vertical-align: middle;width: 15px;height: 15px;"
												update="createForm:createAttachmentCol"
												actionListener="#{noticeManageView.deleteFile(attachment)}">
												<p:confirm header="提示" message="确定删除该附件吗?" icon="ui-icon-alert" />
											</p:commandButton>
										</div>
									</p:repeat>
								</p:outputPanel>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="#{request.contextPath}/resources/js/mymodal.js"></script>
		<script src="#{request.contextPath}/resources/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
		<script src="/resources/js/tables/singleScrollTable.js" />
	</ui:define>
</ui:composition>
